package me.zk.practice1.hw;

import java.util.Arrays;
import java.util.Scanner;

public class HWBJ40 {
    public static void main(String[] args) {

        //28
        //310
        //4
        Scanner scanner = new Scanner(System.in);

        int m = scanner.nextInt();
        int n = scanner.nextInt();
        scanner.nextLine();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        int[] g = new int[m];

        Arrays.sort(nums);
        for (int i = 0; i < n; i++) {
            g[i%m] += nums[i];
        }
        System.out.println(Arrays.stream(g).max().getAsInt());

    }
}
